<template>
	<view class="container">
		<view class="top disb aic">
			<view class="">财富总值</view>
			<view class="fz20 fw">{{wealth}}</view>
		</view>
		<view class="tabName fw">明细</view>
		<view class="wealth">
      <view v-if="Object.keys(wealthList).length === 0">
        <u-empty text="无财富值明细" mode="list"></u-empty>
      </view>
			<view class="wealthList" v-for="item in wealthList" :key="item.id">
				<view class="top disb aic">
					<view class="fz10 color9">{{getTime(item.createTime)}}</view>
					<view class="fz12 color9">
						<text>获得财富值</text>
						<text :class="item.wealthValue>0?'color fw fz14':'colorg fw fz14'">{{item.wealthValue>0?'+':''}}{{item.wealthValue}}</text>
					</view>
				</view>
				<view class="bot fz12">
					<text class="color9">备注：</text>
					<text>{{item.remark}}</text>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	import {getWealth} from "../../api/product.js"
export default {
	data() {
		return {
			wealth:uni.getStorageSync('userInfo').wealthValue,
			wealthList:[]
		}
	},
	onLoad(e) {
		this.getDetail()
	},
	methods: {
		getDetail(){
			getWealth().then(res => {
				this.wealthList = res.data
			})
		},
		//时间戳转换
		getTime(time){
			let data= new Date(time);
			let year = data.getFullYear();
			let month = data.getMonth() + 1;
			let day = data.getDate();
			let h = data.getHours();
			let mm = data.getMinutes();
			let s = data.getSeconds();
			month = month >= 10 ? month : "0" + month;
			day = day >= 10 ? day : "0" + day;
			h = h >= 10 ? h : "0" + h;
			mm = mm >= 10 ? mm : "0" + mm;
			s = s >= 10 ? s : "0" + s;
			return `${year}-${month}-${day} ${h}:${mm}:${s}`;
		},
    },
}
</script>

<style lang="scss" scoped>
.container{
	min-height: 100vh;
	background-color: #f7f7f7;
	.top{
		padding: 30rpx 50rpx;
		background-color: #fff;
	}
	.tabName{
		padding: 30rpx;
	}
	.wealth{
		padding: 30rpx;
		.wealthList{
			margin: 20rpx 0;
			border-radius: 10rpx;
			background-color: #fff;
			.top{
				padding: 20rpx;
				border-bottom: 1rpx solid #f7f7f7;
			}
			.bot{
				padding: 20rpx;
			}
		}
	}
}
</style>
